package tk.mybatis.springboot.util;

import java.sql.*;

public class JdbcExample {

    public static void main(String[] args) {
        String url = "jdbc:mysql://192.168.127.40:3306/root";
        String user="root";
        String password= "root";
        String status = null;
        Connection connection = null;
        Statement statement = null;
        ResultSet resultSet = null;
        try{
            Class.forName("com.mysql.jdbc.Driver");
             connection = DriverManager.getConnection(url,user,password);
             statement = connection.createStatement();
            String sql = "select status from rt_task_opration where task_name=";
            sql +="2024-03-19 18:05:10";
            resultSet = statement.executeQuery(sql);

            while (resultSet.next()){
              status =  resultSet.getString(status);
            }
            System.out.println("状态是"+status);
        }catch (Exception e){
           e.printStackTrace();
        }finally {
            try {
                resultSet.close();
                statement.close();
                connection.close();
            } catch (SQLException ex) {
                throw new RuntimeException(ex);
            }
        }
    }
}
